<!-- src/main/resources/templates/query.html -->
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Fund Valuation Analysis</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 40px; }
        table { border-collapse: collapse; width: 80%; }
        th, td { border: 1px solid #ccc; padding: 8px; text-align: left; }
        th { background-color: #f2f2f2; }
        .form-group { margin: 10px 0; }
    </style>
    <style>
        .bg-green {
            background-color: #d4edda !important;
            color: #155724;
        }
        .bg-red {
            background-color: #f8d7da !important;
            color: #721c24;
        }
        td {
            transition: background-color 0.3s;
        }
    </style>

</head>
<body>
<h1>Fund Undervaluation Rate Query</h1>
<a href="/" class="btn btn-info">index页</a>

<!-- Result Table -->
<div th:if="${result}">
    <div th:each="info : ${result}">
        <h2 th:text="${info.fundNav.fundName}"></h2>
        <p th:text="${info.fundNav.unitNav}"></p>
        <table th:if="${info.fundValuationDTOS}">
            <thead>
            <tr>
                <th>基金代码</th>
                <th>基金名称</th>
                <th>区间</th>
                <th>起始日期</th>
                <th>低于历史估值 (%)</th>
                <th>最小净值</th>
                <th>最大净值</th>
                <th>平均净值</th>
                <th>起始净值</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="item : ${info.fundValuationDTOS}">
                <td th:text="${item.fundCode}"></td>
                <td th:text="${item.fundName}"></td>
                <td th:text="${item.period}"></td>
                <td th:text="${item.startDate}"></td>
                <td th:text="${item.undervaluationRate}"
                    th:classappend="${item.undervaluationRate > 80} ? 'bg-red' :
                   (${item.undervaluationRate < 20} ? 'bg-green' : '')">
                </td>
                <td th:text="${item.unitNavMin}"></td>
                <td th:text="${item.unitNavMax}"></td>
                <td th:text="${item.unitNavAvg}"></td>
                <td th:text="${item.unitNavStart}"></td>
            </tr>
            </tbody>
        </table>
    </div>

</div>

</body>
</html>
